import requests
from bs4 import BeautifulSoup
def get():
    res = requests.get('https://movie.douban.com/',headers={
        'user-agent':"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36"
    })
    movies = []
    # 解析库,解析网页标签,指定解析的样式工具
    # 电影列表
    ht = res.text
    stop = BeautifulSoup(ht,'html.parser')
    rev = stop.find_all('div', class_='review')
    for i in rev:
        movie_title_tag = i.find('div', class_="review-meta").find_all('a')[-1]
        # 电影地址
        movie_url = movie_title_tag['href']
        # print()
        # print(movie_title_tag.text)
        # 电影名称
        texy = movie_title_tag.text.strip().replace("《", "").replace("》", "")
        # print(texy)
        movies.append({"电影名称": texy, "电影地址": movie_url})

    print(movies)


get()
